package xmppjavaclient;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import org.jivesoftware.smack.*;
import org.jivesoftware.smack.packet.*;

public class XMPPJavaClientFrame extends JFrame {

	public XMPPJavaClientFrame() {

		loginPanel = new LoginPanel(this);
		this.add(loginPanel);

		this.setSize(200, 500);
		this.setVisible(true);
		this.addWindowListener(
			new WindowAdapter() {
				@Override
				public void windowClosing(WindowEvent e) {
					XMPPJavaClientFrame.this.windowClosed();
				}
			});
	}

	public void LoginOk()
	{
		this.remove(loginPanel);
		rosterPanel = new RosterPanel(this);
		this.add(rosterPanel);
		this.setVisible(true);
	}

	protected void windowClosed() {
		if (TheGlobal.connection != null && TheGlobal.connection.isConnected()) {
			TheGlobal.connection.disconnect();
		}
		System.exit(0);
	}

	private JPanel loginPanel;
	private JPanel rosterPanel;
}
